package ru.arriah.common.ejb.help;

public class KeyBlock {
   protected int currentKey;
   protected int limit;

   public KeyBlock(int currentKey, int limit) {
      super();

      if (currentKey >= limit) {
         throw new RuntimeException("Can't create empty block");
      }

      this.currentKey = currentKey;
      this.limit = limit;
   }

   public int getCurrentKey() {
      return currentKey;
   }

   public int getLimit() {
      return limit;
   }

   public boolean hasNext() {
      return currentKey < limit;
   }

   public int move() {
      if (!hasNext()) {
         throw new RuntimeException("This block is empty");
      }

      return currentKey++;
   }
}
